feat: add bubble removal animation#1461
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: qxp930712 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Sorry @qxp930712, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
| m_delayBubbles.removeAll(id); | ||
| remove(m_bubbles.indexOf(item)); | ||
| // Emit signal before removing to trigger QML animation | ||
| Q_EMIT bubbleAboutToRemove(id); |
There was a problem hiding this comment.
|
TAG Bot New tag: 2.0.31 |
Changed the bubble panel visibility logic to include a 400ms delay before hiding when there are no notifications. This prevents the panel from disappearing abruptly when the last bubble is removed. The QML ListView now includes a remove transition with smooth exit animation for bubbles. Added QTimer include for delayed hide functionality. Modified the ListView height calculation to use maximum of contentHeight and childrenRect.height to ensure proper layout during animations. Implemented a sequential animation for bubble removal with x-axis slide- out effect. Log: Improved notification bubble animations with smoother hide effects Influence: 1. Test notification bubble appearance and disappearance 2. Verify panel remains visible during bubble removal animations 3. Check that multiple bubbles animate correctly 4. Test edge cases with rapid notification additions/removals 5. Verify panel properly hides after all bubbles are removed 6. Test animation timing and smoothness PMS: BUG-284659
deepin pr auto review这段代码修改主要是为了优化通知气泡的显示与隐藏动画效果,使其更加平滑。以下是对代码的详细审查和改进建议: 1. 语法与逻辑审查C++ 部分 (
QML 部分 (
2. 代码质量改进建议针对 C++ 逻辑缺陷的修复(竞态条件) 建议在 改进后的 C++ 代码示例: // 在 bubblepanel.h 头文件中
class BubblePanel : public ... {
Q_OBJECT
// ...
private:
QTimer *m_hideTimer; // 声明一个定时器成员变量
// ...
};
// 在 bubblepanel.cpp 构造函数中
BubblePanel::BubblePanel(...) {
// ...
m_hideTimer = new QTimer(this);
m_hideTimer->setSingleShot(true);
connect(m_hideTimer, &QTimer::timeout, this, [this]() {
if (m_bubbles->items().isEmpty()) {
setVisible(false);
}
});
// ...
}
// 修改 onBubbleCountChanged 实现
void BubblePanel::onBubbleCountChanged()
{
bool isEmpty = m_bubbles->items().isEmpty();
const bool visible = !isEmpty && enabled();
if (visible) {
// 如果需要显示,停止可能正在运行的隐藏定时器,并立即显示
m_hideTimer->stop();
setVisible(true);
} else {
// 如果需要隐藏,启动定时器(如果已经在运行,restart 会重置时间)
// 这里的 400ms 应与 QML 动画时长保持一致
m_hideTimer->start(400);
}
}改进点解释:
3. 代码性能
4. 代码安全
总结这段代码的初衷是好的(添加平滑过渡动画),但原实现存在一个并发/时序逻辑漏洞(在动画播放期间新通知到达可能导致面板闪烁或错误隐藏)。 建议采纳上述关于引入 |
|
修改方案 |
|
修改方案 |
Log: Notification bubbles will now slide out smoothly when closed instead of disappearing instantly.
Influence:
PMS: BUG-284659